package icom.acm.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtil {	
	
	public static Date now(){
		Calendar calandar = Calendar.getInstance();
		Date date = calandar.getTime();
				
		return date;
	}
	
	public static String s_now(String type){		
		return d2s(type, now());
	}
	
	public static String d2s(String type, Date date){
		SimpleDateFormat sdf = new SimpleDateFormat (type);
		return sdf.format(date);
	}
	
	public static Date s2d(String type, String s_date){
		SimpleDateFormat sdf = new SimpleDateFormat (type);
		try {
			return sdf.parse(s_date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
}
